Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workbox-sw

Package Overview
Dependencies
Maintainers
4
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-sw

This module makes it easy to get started with the Workbox service worker libraries.

  • 5.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
decreased by-52.24%
Maintainers
4
Weekly downloads
 
Created

What is workbox-sw?

The workbox-sw npm package is a library that simplifies service worker creation and management, making it easier to build robust, offline-first web applications. It provides a set of tools to cache assets and other resources, handle background sync, and manage runtime caching strategies.

What are workbox-sw's main functionalities?

Precaching

This feature allows you to specify a list of URLs and their corresponding revision details to be precached when the service worker is installed. This is useful for ensuring that your app's core resources are cached and available offline.

import { precacheAndRoute } from 'workbox-precaching';

precacheAndRoute(self.__WB_MANIFEST);

Runtime Caching

Runtime caching enables you to use various caching strategies for different types of requests. This example uses the NetworkFirst strategy, which tries to fetch the latest content from the network, but falls back to the cache if the network is unavailable.

import { registerRoute } from 'workbox-routing';
import { NetworkFirst } from 'workbox-strategies';

registerRoute(
  ({request}) => request.destination === 'document',
  new NetworkFirst()
);

Background Sync

Background Sync allows you to defer actions until a stable network connection is detected. This is particularly useful for ensuring that user actions, like posting comments, are not lost when the app is offline.

import { BackgroundSyncPlugin } from 'workbox-background-sync';

const bgSyncPlugin = new BackgroundSyncPlugin('myQueueName', {
  maxRetentionTime: 24 * 60 // Retry for max of 24 Hours
});

Other packages similar to workbox-sw

Keywords

FAQs

Package last updated on 09 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc